local skel = fk.CreateSkill {
  name = "lb__pohui",
  tags = { Skill.Hidden },
}

skel.HiddenGeneral = "lb__moze_yinni"

local U = require "packages.utility.utility"

Fk:loadTranslationTable {
  ["lb__pohui"] = "破晦",
  [":lb__pohui"] = "<b>隐匿技</b>，当你登场时，你可将一张【杀】当雷属性的<a href=':unexpectation'>【出其不意】</a>使用。你以此法造成的伤害改为X（X为以下条件中满足的项数："..
  "1.你因<a href=':lb__zhuying'><font color='red'>〖逐影〗</font></a>而登场；"..
  "2.你对其发动过<a href=':lb__zhuying'><font color='red'>〖逐影〗</font></a>；"..
  "3.你首次发动〖破晦〗）。",

  ["#lb__pohui"] = "破晦：你可以一张【杀】当雷属性的【出其不意】使用",

  ["$lb__pohui1"] = "风声所到之处，你无所遁形。",
  ["$lb__pohui2"] = "该收割了。",
  ["$lb__pohui3"] = "幽冥，奔袭！",
}

skel:addEffect(U.GeneralAppeared, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and not player:isNude()
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local use = room:askToUseVirtualCard(player, {
      name = "unexpectation",
      skill_name = skel.name,
      prompt = "#lb__pohui",
      cancelable = true,
      card_filter = {n = 1, pattern = "slash"},
      skip = true,
    })
    if use then
      event:setCostData(self, {use = use})
      return use
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local use = event:getCostData(self).use ---@type UseCardDataSpec
    local num = data.reason == "lb__zhuying" and 1 or 0
    if table.find(use.tos, function (to)
      return table.contains(player:getTableMark("@[player]lb__zhuying"), to.id)
    end) then
      num = num + 1
    end
    if player:usedSkillTimes(skel.name, Player.HistoryGame) == 1 then
      num = num + 1
    end
    use.extra_data = use.extra_data or {}
    use.extra_data.ChangeDamageNum = num
    use.extra_data.ChangeDamageType = fk.ThunderDamage
    room:useCard(use)
  end,
})

return skel